package com.tian.service.impl.market;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.tian.common.util.ChargeMarketRedisKeyPrefix;
import com.tian.common.util.CommonResult;
import com.tian.dto.market.message.ChargeSystemMessageContentAddReqDto;
import com.tian.dto.market.message.ChargeSystemMessageContentRespDto;
import com.tian.entity.ChargeSystemMessageContent;
import com.tian.mapper.ChargeSystemMessageContentMapper;
import com.tian.service.market.ChargeSystemMessageContentService;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * {@code @description:} 站内信内容配置 服务实现类
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-08-10 10:25
 * {@code @version:} 1.0
 */
@Service
public class ChargeSystemMessageContentServiceImpl implements ChargeSystemMessageContentService {

    @Resource
    private ChargeSystemMessageContentMapper chargeSystemMessageContentMapper;

    @Resource
    private RedissonClient redissonClient;

    @Override
    public CommonResult<Boolean> add(ChargeSystemMessageContentAddReqDto chargeSystemMessageContentAddReqDto) {
        ChargeSystemMessageContent chargeSystemMessageContent = new ChargeSystemMessageContent();
        BeanUtil.copyProperties(chargeSystemMessageContentAddReqDto, chargeSystemMessageContent);
        chargeSystemMessageContentMapper.insert(chargeSystemMessageContent);
        redissonClient.getBucket(ChargeMarketRedisKeyPrefix.USER_SYSTEM_MESSAGE_CONTENT_ID_KEY + chargeSystemMessageContent.getId()).set(JSON.toJSON(chargeSystemMessageContent));
        return CommonResult.success(Boolean.TRUE);
    }

    @Override
    public CommonResult<Boolean> delete(Long id) {
        return null;
    }

    @Override
    public CommonResult<ChargeSystemMessageContentRespDto> findById(Long id) {
        return null;
    }
}
